﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DownloadBook {
    public class Content {
        public string title;
        public string url;
        public bool downloadComplete;
        public bool downloading;
        private String mFileName;


        /// <summary>
        /// 获取保存的文件名
        /// </summary>
        /// <returns></returns>
        public String GetFileName(){
            if(mFileName == null){
                string fileName = Path.GetFileName(url);
                char [] invalidChars = Path.GetInvalidFileNameChars();
                for (int i = 0; i < invalidChars.Length; i++) {
                    String cStr = invalidChars[i].ToString();
                    fileName = fileName.Replace(cStr, String.Empty);
                }
                mFileName = fileName;
            }
            return mFileName;
        }

        public override string ToString() {
            return title;
        }
    }
}
